#include "../mars/defer.h"
#include "../mars/logger.h"
#include <boost/bind.hpp>

class DB {
    public:
        void connect() {
            INFO_PRINT("DB connect\n");
        }

        int release(int a) {
            INFO_PRINT("DB %d release\n", a);
            return a;
        }
};

void show() {
    INFO_PRINT("Hello, I'm allen\n");
}

void test1() {
    DB db;
    mars::Defer defer(boost::bind(&DB::release, &db, 5));
    db.connect();
    INFO_PRINT("This is test1\n");
}

void test2() {
    mars::Defer defer(show);
    INFO_PRINT("This is test2\n");
}

int main() {
    test1();
    test2();
    return 0;
}
